
IF ( QT4_FOUND )
  INCLUDE( ${QT_USE_FILE} )
  SET(LIBS ${LIBS} ${QT_LIBRARIES}) 
ENDIF( QT4_FOUND )

FIND_PACKAGE ( VTK )

  IF ( VTK_FOUND )
    INCLUDE( ${USE_VTK_FILE} )
  ENDIF( VTK_FOUND )

FIND_PATH(DATA_ROOT aal.csv 
  ${BrainFunc_SOURCE_DIR}/Data 
  $ENV{DATA_ROOT})

FIND_PACKAGE(ZLIB REQUIRED)
INCLUDE_DIRECTORIES ( ${ZLIB_INCLUDE_DIRS} )
LINK_DIRECTORIES    ( ${ZLIB_LIBRARY_DIRS} )

FIND_PACKAGE(Matio REQUIRED)
INCLUDE_DIRECTORIES ( ${MATIO_INCLUDE_DIRS} )
LINK_DIRECTORIES    ( ${MATIO_LIBRARY_DIRS} )

FIND_PACKAGE(Qwt5 REQUIRED)
INCLUDE_DIRECTORIES ( ${Qwt5_INCLUDE_DIR} )
LINK_DIRECTORIES    (  ${Qwt5-Qt4_LIBRARY} )

INCLUDE_DIRECTORIES (
  ${QT_INCLUDE_DIR}
  ${BrainFunc_SOURCE_DIR}
  ${BrainFunc_SOURCE_DIR}/src
  ${BrainFunc_BINARY_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
)

SET(BrainFunc_SRCS
    main.cpp
    mainwindow.cpp
    centralwindow.cpp
    opendatawizard.cpp
    correlationmatrix.cpp
    asynchronousworker.cpp
    anatomicaltemplate.cpp
    regioninfo.cpp
    functionalnetwork.cpp
    anatomicalregion.cpp
    loaderwizardpage.cpp
    colormap.cpp
    dialog.cpp
    anatomicallink.cpp
    correlationfilter.cpp
    distancefilter.cpp
    views/hierarchicalbundleview.cpp
    views/taiyunview.cpp
    views/taiyun.cpp
    views/filterview.cpp
    views/linkview.cpp
    views/regionview.cpp
    views/abstractView.cpp
    views/scatterplotview.cpp
    view3dinteractorstyle.cpp
    views/infoview.cpp
    deviationfromexpectfilter.cpp
    heatmap.cpp
)

SET(BrainFunc_UIS
    mainwindow.ui
    centralwindow.ui
    opendatawizard.ui
    loaderwizardpage.ui
    dialog.ui
    views/hierarchicalbundleview.ui
    views/taiyunview.ui
    views/filterview.ui
    views/linkview.ui
    views/regionview.ui
    views/scatterplotview.ui
    views/infoview.ui
)

SET(BrainFunc_HDRS
    mainwindow.h
    centralwindow.h
    opendatawizard.h
    correlationmatrix.h
    asynchronousworker.h
    anatomicaltemplate.h
    regioninfo.h
    functionalnetwork.h
    anatomicalregion.h
    loaderwizardpage.h
    dialog.h
    anatomicallink.h
    linkfilter.h
    correlationfilter.h
    distancefilter.h
    views/hierarchicalbundleview.h
    views/taiyunview.h
    views/taiyun.h
    views/filterview.h
    views/linkview.h
    views/regionview.h
    views/abstractView.h
    views/infoview.h
    views/scatterplotview.h
    view3dinteractorstyle.h
    deviationfromexpectfilter.h
    heatmap.h
    colormap.h
)

SET(BrainFunc_MOC_HDRS
    mainwindow.h
    centralwindow.h
    opendatawizard.h
    correlationmatrix.h
    asynchronousworker.h
    anatomicaltemplate.h
    regioninfo.h
    functionalnetwork.h
    anatomicalregion.h
    loaderwizardpage.h
    dialog.h
    anatomicallink.h
    linkfilter.h
    correlationfilter.h
    distancefilter.h
    views/hierarchicalbundleview.h
    views/taiyunview.h
    views/taiyun.h
    views/filterview.h
    views/linkview.h
    views/regionview.h
    views/infoview.h
    views/abstractView.h
    views/scatterplotview.h
    view3dinteractorstyle.h
    colormap.h
    deviationfromexpectfilter.h
    heatmap.h
)

ADD_DEFINITIONS(-DDATA_ROOT=\"${DATA_ROOT}\")

SET(BrainFunc_RCCS application.qrc)

QT4_WRAP_CPP(BrainFunc_MOC_SRCS ${BrainFunc_MOC_HDRS})

QT4_WRAP_UI(BrainFunc_UIS_H ${BrainFunc_UIS})

QT4_AUTOMOC( ${BrainFunc_SRCS} )

QT4_ADD_RESOURCES(BrainFunc_RCCS_SRC ${BrainFunc_RCCS})

#IF(WIN32)
# SET(GUI_TYPE WIN32)
#ENDIF(WIN32)

#IF (APPLE)
#  SET(GUI_TYPE MACOSX_BUNDLE)
#ENDIF (APPLE)

#SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
#  IF(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64")
#    SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#  ENDIF(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64")

ADD_EXECUTABLE(BrainFunc ${GUI_TYPE} ${BrainFunc_SRCS} ${BrainFunc_MOC_SRCS} ${BrainFunc_HDRS} ${BrainFunc_UIS_H} ${BrainFunc_RCCS_SRC} appicon.rc)

TARGET_LINK_LIBRARIES ( 
  BrainFunc
  ${QT_LIBRARIES}
  vtkRendering
  vtkGraphics
  vtkIO
  vtkFiltering
  vtkCommon
  QVTK
  ${MATIO_LIBRARIES}
  ${Qwt5_Qt4_LIBRARY}
  ${ZLIB_LIBRARIES}
)
# INSTALL(FILES ${QT_LIBRARIES} DESTINATION lib)

#INSTALL(TARGETS BrainFunc
#  BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX}/fubraConnex
#  RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/fubraConnex
#  LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/fubraConnex/lib
#)

#INSTALL(FILES ${QT_LIBRARIES} DESTINATION bin)

#INCLUDE(InstallRequiredSystemLibraries)
#INCLUDE(BundleUtilities)

#INCLUDE(CPack)
#FIXUP_BUNDLE("${APPS}" "${TARGET_LINK_LIBRARIES}" "LIBS")

#  ${QT_LIBRARY_DIR}/qtmain.lib
# PATH=E:\SDK\VTK-5.4.2-build\bin\$(OutDir);E:\SDK\InsightToolkit-3.14.0-build\bin\$(OutDir);E:\SDK\qwt-5.2\lib\$(OutDir);E:\SDK\qt-win32-4.6.1\lib;%PATH%;
